using System;
using System.ComponentModel;
using System.Collections.Generic;

namespace shfa.snomtastic.data.business
{
	[DataObject(true)]
    public partial class ConfigurationSettingController
    {
	
		public SqlDataProvider DataProvider { get; set; }

        public ConfigurationSettingController()
        {
            DataProvider = new SqlDataProvider();
        }
	
		[DataObjectMethod(DataObjectMethodType.Insert, true)]
        public Guid InsertConfigurationSetting(ConfigurationSettingInfo oi)
		{
            return DataProvider.InsertConfigurationSetting(oi.ConfigurationId, oi.SettingId, oi.Active, oi.PermissionFlag, oi.Value, oi.Pattern, oi.Replacement);
		}

		[DataObjectMethod(DataObjectMethodType.Update, true)]
        public int UpdateConfigurationSetting(ConfigurationSettingInfo oi) 
		{
			return DataProvider.UpdateConfigurationSetting(oi.ConfigurationId, oi.SettingId, oi.Active, oi.PermissionFlag, oi.Value, oi.Pattern, oi.Replacement);
		}
		
		[DataObjectMethod(DataObjectMethodType.Delete, true)]
        public int DeleteConfigurationSetting(Guid configurationId, Guid settingId)
		{
			return DataProvider.DeleteConfigurationSetting(configurationId, settingId);
        }

		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public ConfigurationSettingInfo SelectConfigurationSetting(Guid configurationId, Guid settingId)
        {    
			return ObjectFromDataRow(DataProvider.SelectConfigurationSetting(configurationId, settingId));
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public List<ConfigurationSettingInfo> SelectConfigurationSettings()
		{
            return ListFromDataTable(DataProvider.SelectConfigurationSettings());
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public List<ConfigurationSettingInfo> SelectConfigurationSettings(string sortExpression)
        {
            List<ConfigurationSettingInfo> retList = SelectConfigurationSettings();
            if (sortExpression.Length > 0)
            {
                retList.Sort(new ConfigurationSettingComparer(sortExpression));
            }
            return retList;
        }

        [DataObjectMethod(DataObjectMethodType.Select, true)]
		public List<ConfigurationSettingInfo> SelectConfigurationSettingsByConfiguration(Guid configurationId)
		{
			return ListFromDataTable(DataProvider.SelectConfigurationSettingsByConfiguration(configurationId));
		}
		
        public List<ConfigurationSettingInfo> SelectConfigurationSettingsByConfiguration(Guid configurationId,string sortExpression)
		{
			List<ConfigurationSettingInfo> retList = SelectConfigurationSettingsByConfiguration(configurationId);
            if (sortExpression.Length > 0)
            {
                retList.Sort(new ConfigurationSettingComparer(sortExpression));
            }
            return retList;
		}

        [DataObjectMethod(DataObjectMethodType.Select, true)]
		public List<ConfigurationSettingInfo> SelectConfigurationSettingsBySetting(Guid settingId)
		{
			return ListFromDataTable(DataProvider.SelectConfigurationSettingsBySetting(settingId));
		}
		
        public List<ConfigurationSettingInfo> SelectConfigurationSettingsBySetting(Guid settingId,string sortExpression)
		{
			List<ConfigurationSettingInfo> retList = SelectConfigurationSettingsBySetting(settingId);
            if (sortExpression.Length > 0)
            {
                retList.Sort(new ConfigurationSettingComparer(sortExpression));
            }
            return retList;
		}

	}

}
		